#include <topology.h>
Inheritance diagram for mudbox::Topology:
Since only full triangle or quad meshes are allowed in Mudbox, an instance of this class is basically an array of triangles and quads. When a mixed triangle-quad or n-sided mesh is imported into mudbox, then the mesh is converted to a full triangle topology, see the member functions IsFakeTriangle and SetFakeTriangle. The Topology class can hold different type of data for the polygons, like position indices, adjacency, texture coordinate indices etc. These are called face components. To save memory not every buffer is allocated at the beginning. You can control which buffers will be allocated by calling the AddFaceComponent() and RemoveFaceComponent() functions.
Public Types |
|
enum | FaceState { fsSelected = 0x01, fsVisible = 0x02, fsFake = 0x04, fsActive = 0x08, fsMapped = 0x10 } |
enum | FaceComponent { fcIndex = 1, fcAdjacency = 2, fcTCIndex = 4, fcNormal = 8, fcID = 16, fcOctree = 32, fcFreeze = 64, fcState = 128 } |
enum | FaceType { typeTriangular, typeQuadric } |
Public Member Functions |
|
void | MoveTo (Topology *pDestination) |
This object will loose all data and become
an empty topology. |
|
void | CopyTo (Topology *pDestination) const |
This function is similar to MoveTo, but
since it is copying all the data, it is slower. |
|
void | Serialize (Stream &s) |
serializes the content of the object
into/from a stream. |
|
FaceType | Type (void) const |
Returns the type of the topology. Can be
full triangular or full quadric. |
|
void | SetType (FaceType eType) |
Sets the type of the object. This call also
clears all the content of the object. |
|
int | SideCount (void) const |
Returns the number of sides in the faces.
This is three if the topology is triangle based, and four if its
quad based. |
|
unsigned int | FaceCount (void) const |
Returns the number of faces in the topology.
|
|
virtual Vector | FaceNormal (unsigned int iFaceIndex) const |
Returns the normal vector for a face in the
topology. |
|
void | SetFaceID (unsigned int iFaceIndex, unsigned int iID) |
This function is used only internally.
|
|
unsigned int | FaceID (unsigned int iFaceIndex) const |
This function is used only internally.
|
|
virtual void | SetFakeTriangleCount (unsigned int iFakeTriangleCount) |
Call this method to indicate how many fake
triangles are in the topology. |
|
unsigned int | QuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const |
Returns the vertex position index of a
corner of a quad. |
|
void | SetQuadIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue) |
Sets the vertex position index of a corner
of a quad. |
|
unsigned int | QuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const |
Returns the vertex texture coordinate index
of a corner of a quad. |
|
void | SetQuadTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue) |
Sets the vertex texture coordinate index of
a corner of a quad. |
|
virtual unsigned int | QuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const |
Returns the vertex adjacency information
index of a side of a quad. |
|
unsigned int | QuadAdjacency_ForcedInline (unsigned int iFaceIndex, unsigned int iSideIndex) const |
virtual void | SetQuadAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue) |
Sets the adjacency info for a side of a
quad. See QuadAdjacency for details. |
|
bool | HasAdjacentQuad (unsigned int iFaceIndex, unsigned int iSideIndex) const |
Returns true if the given edge of a quad has
an adjacent quad on the other side. |
|
unsigned int | TriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex) const |
Returns the vertex position index of a
corner of a triangle. |
|
void | SetTriangleIndex (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue) |
Sets the vertex position index of a corner
of a triangle. |
|
unsigned int | TriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex) const |
Returns the vertex texture coordinate index
of a corner of a triangle. |
|
void | SetTriangleTCI (unsigned int iFaceIndex, unsigned int iCornerIndex, unsigned int iValue) |
Sets the vertex texture coordinate index of
a corner of a triangle. |
|
virtual unsigned int | TriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex) const |
Returns the vertex adjacency information
index of a side of a triangle. |
|
virtual void | SetTriangleAdjacency (unsigned int iFaceIndex, unsigned int iSideIndex, unsigned int iValue) |
Sets the adjacency info for a side of a
triangle. See TriangleAdjacency for details. |
|
bool | HasAdjacentTriangle (unsigned int iFaceIndex, unsigned int iSideIndex) const |
Returns true if the given edge of a triangle
has an adjacent triangle on the other side. |
|
unsigned char & | FaceState (unsigned int iFaceIndex) |
Returns the state of a face. See FaceState.
|
|
unsigned char | FaceState (unsigned int iFaceIndex) const |
Sets the state of a face. |
|
bool | IsFaceSelected (unsigned int iFaceIndex) const |
Returns true if the given face is selected.
|
|
virtual void | SetFaceSelected (unsigned int iFaceIndex, bool bSelected=true, bool bUpdateVertexSelection=false, bool bBatchSelection=false) |
Sets selection state for a face. |
|
bool | IsFaceVisible (unsigned int iFaceIndex) const |
Returns true if the given face is visible.
|
|
void | SetFaceVisible (unsigned int iFaceIndex, bool bSelected=true) |
Sets the visibility of a given face.
|
|
bool | IsFaceActive (unsigned int iFaceIndex) const |
void | SetFaceActive (unsigned int iFaceIndex, bool bSelected=true) |
bool | IsFaceMapped (unsigned int iFaceIndex) const |
Used only internally. |
|
void | SetFaceMapped (unsigned int iFaceIndex, bool bSelected=true) |
Used only internally. |
|
bool | IsFakeTriangle (unsigned int iTriangleIndex) const |
This function can only be used for
triangular meshes. |
|
void | SetFakeTriangle (unsigned int iTriangleIndex, bool b) |
bool | IsFaceTemp (unsigned int iFaceIndex) const |
void | SetFaceTemp (unsigned int iFaceIndex, bool bSelected=true) |
void | ClearFaceTempStates () |
virtual void | AddFaceComponent (FaceComponent eComponentToAdd) |
Adds new face component(s) to the object.
|
|
virtual void | RemoveFaceComponent (FaceComponent eComponentToRemove) |
Removes face component(s) from the object.
This might delete some data from the memory. |
|
unsigned int | FaceComponents (void) const |
Returns the current face components for the
object. |
|
void | SetFaceCount (unsigned int iFaceCount) |
Sets the number of faces in the object.
Existing face data will be kept. |
|
virtual bool | SetAdjacencyCount (unsigned int iCount, bool bKeepContent=true, bool bForced=false) |
Sets the size of the adjacency array.
|
|
unsigned int | AdjacencyCount (void) const |
Returns the size of the adjacency matrix.
|
|
bool | HasTC (void) const |
Returns true if the mesh has texture
coordinates. |
|
Public Attributes |
|
Store< unsigned int > | m_pIndices |
Protected Member Functions |
|
Topology (void) | |
Do not use constructors directly. Use
CreateInstances() instead.
|
|
Topology (FaceType eType) | |
Constructs the object with zero faces.
|
|
Friends |
|
class | ::XMesh |
|
00052 { 00053 fsSelected = 0x01, 00054 fsVisible = 0x02, 00055 fsFake = 0x04, 00056 fsActive = 0x08, 00057 fsMapped = 0x10, 00058 // fsTemp = 0x20 // for performance reasons, the temp state is split into a seperate vector 00059 }; |
|
|
00073 { 00074 typeTriangular, 00075 typeQuadric 00076 }; |
|
Do not use constructors directly. Use CreateInstances() instead. |
|
Constructs the object with zero faces. |
|
This object will loose all data and become an empty topology. |
|
This function is similar to MoveTo, but since it is copying all the data, it is slower. You can use this function when you want to do some temporary change to a mesh (like you want to change the vertex ordering inside faces) but then you want to restore the original state. In that case you can simply create a copy of the mesh, do the modifications, and when you don't need it any longer, just delete it. |
|
serializes the content of the object into/from a stream. Reimplemented from mudbox::TreeNode. |
|
Returns the type of the topology. Can be full triangular or full quadric.
00115 { return m_eType; };
|
|
Sets the type of the object. This call also clears all the content of the object. |
|
Returns the number of sides in the faces. This is three if the topology is triangle based, and four if its quad based. 00119 { return Type() == typeTriangular ? 3 : 4; }; |
|
Returns the number of faces in the topology.
00123 { return m_iFaceCount; };
|
|
Returns the normal vector for a face in the topology. |
|
This function is used only internally. 00127 { m_pFaceIDs[iFaceIndex] = iID; }; |
|
This function is used only internally.
00129 { return m_pFaceIDs[iFaceIndex]; };
|
|
Call this method to indicate how many fake triangles are in the topology. Call SetFaceCount before calling this method. Note this has no effect on quadric meshes. |
|
Returns the vertex position index of a corner of a quad. The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh. 00137 { return m_pIndices[iFaceIndex*4+iCornerIndex]; }; |
|
Sets the vertex position index of a corner of a quad. The value returned by this call can be used as parameter for the VertexTC() function in class Mesh. 00140 { m_pIndices[iFaceIndex*4+iCornerIndex] = iValue; }; |
|
Returns the vertex texture coordinate index of a corner of a quad.
00142 { return m_pTCI[iFaceIndex*4+iCornerIndex]; }
|
|
Sets the vertex texture coordinate index of a corner of a quad. 00144 { m_pTCI[iFaceIndex*4+iCornerIndex] = iValue; } |
|
Returns the vertex adjacency information index of a side of a quad. If the returned value is x, then x/4 is the index of the adjacent quad, while x%4 is the side in the adjacent quad which is common with the given one.
00148 { return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
|
|
00149 { return m_pAdjacency[iFaceIndex*4+iSideIndex]; }
|
|
Sets the adjacency info for a side of a quad. See QuadAdjacency for details. 00152 { m_pAdjacency[iFaceIndex*4+iSideIndex] = iValue; } |
|
Returns true if the given edge of a quad has an adjacent quad on the other side. 00154 { return QuadAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; }; |
|
Returns the vertex position index of a corner of a triangle. The value returned by this call can be used as a patameter for the VertexPosition() function in class Mesh. 00159 { return m_pIndices[iFaceIndex*3+iCornerIndex]; }; |
|
Sets the vertex position index of a corner of a triangle. 00161 { m_pIndices[iFaceIndex*3+iCornerIndex] = iValue; }; |
|
Returns the vertex texture coordinate index of a corner of a triangle.
00163 { return m_pTCI[iFaceIndex*3+iCornerIndex]; }
|
|
Sets the vertex texture coordinate index of a corner of a triangle. The value returned by this call can be used as parameter for the VertexTC() function in class Mesh. 00166 { m_pTCI[iFaceIndex*3+iCornerIndex] = iValue; } |
|
Returns the vertex adjacency information index of a side of a triangle. If the returned value is x, then x/3 is the index of the adjacent triangle, while x%3 is the side in the adjacent triangle which is common with the given one.
00170 { return m_pAdjacency[iFaceIndex*3+iSideIndex]; }
|
|
Sets the adjacency info for a side of a triangle. See TriangleAdjacency for details. 00173 { m_pAdjacency[iFaceIndex*3+iSideIndex] = iValue; } |
|
Returns true if the given edge of a triangle has an adjacent triangle on the other side. 00176 { return TriangleAdjacency( iFaceIndex, iSideIndex ) < 0x80000000; }; |
|
Returns the state of a face. See FaceState.
00179 { return m_pFaceState[iFaceIndex]; };
|
|
Sets the state of a face.
00181 { return m_pFaceState[iFaceIndex]; };
|
|
Returns true if the given face is selected. 00184 { return (FaceState( iFaceIndex ) & fsSelected) != 0; }; |
|
Sets selection state for a face. The parameter bUpdateVertexSelection controls if the internal buffers should be updated or not. Passing true as this parameter makes the function slow, so do that only if you want to change the selection status for a few faces only. Otherwise use false, and after you changed all the vertices, update the buffers once only. [HOW? OPEN QUESTION] |
|
Returns true if the given face is visible. 00191 { return (FaceState( iFaceIndex ) & fsVisible) != 0; }; |
|
Sets the visibility of a given face. |
|
00195 { return (FaceState( iFaceIndex ) & fsActive) != 0; }; |
|
|
Used only internally. 00199 { return (FaceState( iFaceIndex ) & fsMapped) != 0; }; |
|
Used only internally. |
|
This function can only be used for triangular meshes. If the mesh only contains triangles, then this function always return false. When the original mesh was a mixed tri-quad or n-sided one, then during import it gets converted into a triangular mesh. Each polygon which has more than tree sides are converted into N-2 triangles where N is the number of sides in the polygon. The first triangle is marked as real, but the other ones are marked as fake by this function. So this function makes it possible to restore the original polygon structure of the mesh. |
|
|
00218 { return m_pFaceTemp[iFaceIndex]; };
|
|
00220 { m_pFaceTemp[iFaceIndex] = bSelected; } |
|
00224 { 00225 MB_ASSERT(m_iFaceCount <= m_pFaceTemp.ItemCount()); 00226 memset(&m_pFaceTemp[0], 0, m_iFaceCount); // memset is the fastest way to clear the array. 00227 } |
|
Adds new face component(s) to the object. If the specified components did not exist yet, memory will be allocated for them. |
|
Removes face component(s) from the object. This might delete some data from the memory. |
|
Returns the current face components for the object.
00236 { return m_eFaceComponents; };
|
|
Sets the number of faces in the object. Existing face data will be kept. |
|
Sets the size of the adjacency array. |
|
Returns the size of the adjacency matrix.
00242 { return m_pAdjacency.ItemCount(); };
|
|
Returns true if the mesh has texture coordinates. 00245 { return (FaceComponents() & fcTCIndex) != 0; }; |
|
|